<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="./css/showme.css">
    <script type="text/javascript" src="scripts/jquery/jquery-1.7.1.js"></script>
</head>
<body>
    <form id="user">
        <div id="con">
            <div>
                <label for="stuId">学&emsp;&emsp;号</label>
                <input type="text" id="stuId" name="stuId" readonly="true" autocomplete="off">
            </div>
            <div>
                <label for="stuName">姓&ensp;&ensp;名</label>
                <input type="text" id="stuName" name="stuName" required>
            </div>
            
            <div>
                <label for="major">职&emsp;&emsp;位</label>
                <input type="text" id="major" name="major" autocomplete="off" required>
            </div>
            <div>
                <label for="stuAcademy">系&emsp;&emsp;别</label>
                <input type="text" id="stuAcademy" readonly="true" name="stuAcademy" autocomplete="off" required>
            </div>
            <div>
                <label for="entryData">入学时间</label>
                <input type="month" id="entryDate" readonly="true" name="entryDate" autocomplete="off" required>
            </div>
            <div>
                <label for="stuBirth">出生日期</label>
                <input type="date" id="stuBirth" name="stuBirth" autocomplete="off" required>
            </div>
            <div style="background-color: white;text-align: left;">
                <label style="width: 21%;height: 30px;line-height: 30px;background-color: darkorange;">性&emsp;&emsp;别</label>
                <span style="margin-top:3px;color: black;">
					&nbsp;&nbsp;&nbsp;&nbsp;男&nbsp;&nbsp;<input type="radio" name="stuGender" class="gcs-radio" id="boy" value="男"/><label for="boy"></label>
					&nbsp;&nbsp;&nbsp;&nbsp;女&nbsp;&nbsp;<input type="radio" name="stuGender" class="gcs-radio" id="girl" value="女"/><label for="girl"></label>
				</span>
            </div>
            <div style="background-color: white;text-align: left;">
                <input type="button" id="submit" value="修改资料"/>
            </div>
        </div>
    </form>
    <script type="text/javascript">
    $.ajax({
		type:"post",//请求类型
		url:"/EDUSystem/student/getinfo.do?stuId=00000",
		dataType:"json",//响应的数据类型
		data:"",
		success:function suc(dt){//响应成功后的回调函数
			if(dt.code==1){
				$("#stuId").val(dt.data.stuId);
				$("#stuName").val(dt.data.stuName);
				$("#stuAcademy").val(dt.data.stuAcademy);
				$("#major").val(dt.data.major);
				$("#stuBirth").val(dt.data.stuBirth);
				$("#entryDate").val(dt.data.entryDate);
				if(dt.data.stuGender=='男'){
					$("#boy").attr("checked",'checked');
				}else if(dt.data.stuGender=='女'){
					$("#girl").attr("checked",'checked');
				}
			}else{
				alert(dt.message);
			}
		},
		errer:function err(){
			alert("服务器出现故障")
		}
	});
    $("#submit").click(function(){
    	if(confirm("确认修改?")){
    		$.ajax({
    			type:"post",//请求类型
    			url:"/EDUSystem/student/updatestu.do",//请求路径
    			dataType:"json",//响应的数据类型
    			data:$("#user").serialize(),
    			success:function suc(dt){//响应成功后的回调函数
    				if(dt.code==1){
    					//window.close();
    					alert("修改成功！");
    					location.reload()
    				}else{
    					alert(dt.message);
    				}
    				
    				//location.href="stu_list.jsp";
    			},
    			errer:function err(){
    				alert("服务器出现故障")
    			}
    		});
    	}
    	
    })
    </script>
</body>
</html>